﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

using System.Data.SQLite;

namespace APX
{
   class Employee
   {
      String name, phone;
      List<String> offices;

      public Employee(SQLiteDataReader record)
      {
         name = record["Name"].ToString();
         phone = record["Phone"].ToString();
         String o = record["Office"].ToString();

         offices = new List<string>();
         String[] os = o.Split(';');

         foreach (String x in os)
         {
            offices.Add(x);
         }
      }

      public String Name
      {
         get { return name; }
         set { name = value; }
      }
      public String Phone
      {
         get { return phone; }
         set { phone = value; }
      }
      public List<String> OfficeList
      {
         get { return offices; }
      }
      public void AddOffice(String where)
      {
         offices.Add(where);
      }
   }

   class Office
   {
      String location, headTech;
      DateTime year;

      public Office(SQLiteDataReader row)
      {
         location = row["Location"].ToString();
         year = DateTime.Parse(row["Season"].ToString());
         headTech = row["HeadTech"].ToString();
      }

      public String Where
      {
         get { return location; }
         set { location = value; }
      }
      public int When
      {
         get { return year.Year; }
      }
      public String HeadTech
      {
         get { return headTech; }
         set { headTech = value; }
      }
   }

   class CallStation
   {
      String prefix, phone;

      public CallStation(String pre, String pho)
      {
         prefix = pre;
         phone = pho;
      }

      public String Prefix
      {
         get { return prefix; }
         set { prefix = value; }
      }
      public String Phone
      {
         get { return phone; }
         set { phone = value; }
      }
   }

   class Account
   {
      Dictionary<String, String> customer;
      Dictionary<String, String> account;
      Dictionary<String, int> sensors;
      DateTime installDate;
      Employee salesRep;
      Office installingOffice;
      int points;

      public Account(SQLiteDataReader row)
      {
         customer = new Dictionary<string, string>();
         account = new Dictionary<string, string>();
         sensors = new Dictionary<string, int>();

         salesRep = new Employee(row);
         installingOffice = new Office(row);

         customer["Name"] = row["Customer"].ToString();
         customer["Address"] = row["Address"].ToString();
         customer["City"] = row["City"].ToString();
         customer["State"] = row["State"].ToString();
         customer["Zip"] = row["Zip"].ToString();
         customer["Phone"] = row["Phone"].ToString();

         installDate = DateTime.Parse(row["Date"].ToString());
         account["AR"] = row["AR"].ToString();
         account["CSID"] = row["CSID"].ToString();

         account["Panel"] = row["Panel"].ToString();
         account["Commo"] = row["Commo"].ToString();
         account["Final"] = row["Final"].ToString();
         account["TwoWay"] = row["TwoWay"].ToString();
         account["Comments"] = row["Comments"].ToString();
         account["Upgrades"] = row["Upgrades"].ToString();

         points = int.Parse(row["Points"].ToString());

         sensors["5816"] = int.Parse(row["DoorWindow"].ToString());
         sensors["5818"] = int.Parse( row["Recessed"].ToString() );
         sensors["5853"] = int.Parse( row["Glassbreak"].ToString() );
         sensors["5894"] = int.Parse( row["Motion"].ToString() );
         sensors["5808"] = int.Parse( row["Smoke"].ToString() );
         sensors["5804"] = int.Parse( row["Keyfob"].ToString() );
         sensors["5878"] = int.Parse( row["Wallfob"].ToString() );
         sensors["5802"] = int.Parse( row["Panic"].ToString() );
      }

      public Dictionary<String, String> Customer { get { return customer; } }
      public Dictionary<String, String> Info { get { return account; } }
      public Dictionary<String, int> Sensors { get { return sensors; } }
   }
}
